<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/jquery-weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/index.css" />
		<link rel="stylesheet" type="text/css" href="../../css/demand.css" />
		<link rel="stylesheet" type="text/css" href="https://at.alicdn.com/t/font_546019_o8qxm6fupb0ggb9.css" />
		<title>需求</title>
		<script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/baseConfig.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<style type="text/css">
		.fl-left{
			position:relative
		}
		.fl-left img{
			width: 100% !important;
			height: 100% !important;
			left: 0 !important;
			top: 0 !important;
			position: absolute;
		}
	</style>
	<body>
		<!--<div id="header">
			<div class="header-title" style="position: fixed;top: 0;">
				<img src="../../img/left.png" class="left" />
				<span>需求</span>
			</div>
		</div>-->
		<ul class="warp_swiper" style="margin-top: 0;">
			<!--<li class="swiperList">
				<div class="fl-left">
					<img src="../../img/squarePhoto.png" />
				</div>
				<div class="fl-right">
					<h4>冰箱压缩机</h4>
					<p>
						<span>价格：电议或面议</span>
					</p>
					<p>
						<span>数量：不限</span>
						<span class="area">地区：不限</span>
					</p>
				</div>
			</li>-->
		</ul>
		<p id="content"></p>

		<div id="footer">
			<div class="weui-tabbar" style="position: fixed;">
				<a href="../demand/demand.html" data-info='1' class="weui-tabbar__item weui-bar__item--on">
					<div class="weui-tabbar__icon">
						<img src="../../img/footgreen1.png" class="show" />
					</div>
					<p class="weui-tabbar__label">需求</p>
				</a>
				<a href="../information/information.html" data-info='2' class="weui-tabbar__item">
					<div class="weui-tabbar__icon">
						<img src="../../img/foot2.png" class="show" />
					</div>
					<p class="weui-tabbar__label">资讯</p>
				</a>
				<a href="../order/orderList.html" data-info='3' class="weui-tabbar__item ">
					<div class="weui-tabbar__icon">
						<img src="../../img/foot3.png" class="show" />
					</div>
					<p class="weui-tabbar__label">订单</p>
				</a>
				<a href="../mine/mine.html" data-info='4' class="weui-tabbar__item ">
					<div class="weui-tabbar__icon">
						<img src="../../img/foot4.png" class="show" />
					</div>
					<p class="weui-tabbar__label">我的</p>
				</a>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		$(document).ready(function() {
			baseConfig.historyBack();
			$.showLoading("加载中...");
			function HTMLEncode(text) {
				var temp = document.createElement("p");
				temp.innerHTML = text;
				var output = temp.innerText || temp.textContent
				temp = null
				return output
			}
			baseConfig.login();
			$.ajax({
				type: "get",
				url: baseConfig.localHttp + "weChatApi/fgclient/getFgNeedInfo",
				async: false,
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				success: function(data) {
					$.hideLoading();
					console.log(data)
					
					if(data.code == 100) {
						var $li = ""
						var content = data.content
						for(var i = 0; i < content.length; i++) {
							$li += "<li class='swiperList' data-id=" + content[i].id + "><div class='fl-left'>"+HTMLEncode(content[i].content)+"</div>"
							$li += "<div class='fl-right'><h4>" + content[i].title + "</h4><p>"
							if(content[i].isFacePrice == 0) {
								$li += "<span>价格：" + content[i].lowestPrice + "~" + content[i].highPrice + "</span></p>"
							} else {
								$li += "<span>价格：电议或面议</span></p>"
							}
							if(content[i].isFaceCount == 0) {
								$li += "<p><span>数量：" + content[i].minCount + "~" + content[i].maxCount + "</span>"
							} else {
								$li += "<p><span>数量：不限</span>"
							}
							if(content[i].isArea == 1) {
								$li += "<span class='area'>地区：不限</span></p></div></li>"
							} else {
								$li += "<span class='area'>地区：" + content[i].areaName + "</span></p></div></li>"
							}
						}
						$(".warp_swiper").append($li)
						for(var i=0;i<$(".fl-left").length;i++){		
							if(!$(".fl-left").eq(i).find("div").html()){
								$(".fl-left").eq(i).html("<img src='../../img/squarePhoto.png'>")
							}else{
								$(".fl-left").eq(i).html($(".fl-left").eq(i).find("div").html())
							}
							$(".fl-left img").css("width","100%")
						}
						
						for(var j = 0; j < $(".warp_swiper li").length; j++) {
							$(".warp_swiper li").eq(j).on("click", function() {
								var id = $(this).attr("data-id");
								location.href = "demandInformation.html?id=" + id
							})
						}
					} else {
						$.toptip(data.content, 1200, 'error');
					}
				},
				error: function() {
					$.hideLoading();
					$.toast("请求失败", "cancel");
				}
			})
		})
	</script>

</html>